//
//  WFBaseUIlabel.m
//  谷居
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFBaseUIlabel.h"

@implementation WFBaseUIlabel

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setColor];
        [self addObserver];
        
    }
    return self;
}
- (void)setColor {
    if (!IS_LONG) {
        self.backgroundColor = DAY_COLOR;
        self.textColor = [UIColor blackColor];
    } else {
        self.backgroundColor = NIGHT_COLOR;
        self.textColor = [UIColor lightTextColor];
    }
}
- (void)addObserver {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];
}
-(void)changeToNight:(NSNotification *)sender {
    if (!IS_LONG) {
        self.backgroundColor = NIGHT_COLOR;
        self.textColor = [UIColor lightGrayColor];
    } else {
        self.backgroundColor = DAY_COLOR;
        self.textColor = NIGHT_COLOR;
    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter]removeObserver:self];
    [super dealloc];
}
@end
